package com.example.demo.mapper;
import com.example.demo.entity.File;
import com.example.demo.entity.Folder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SearchMapper {
    @Select("select * from folder where path=#{path}")
    Folder selectFolderByPath(String path);//获取分享链接

//be_new ,be_share
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc,create_datetime asc")
    List<File> groupByCreateTime(String keywords,String username);//按创建时间来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc,create_datetime desc")
    List<File> groupByCreateTime2(String keywords,String username);//按创建时间来查询，降序，有keyWords

    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by  be_top desc,last_update_datetime asc")
    List<File> groupByUpdateTime(String keywords,String username);//按修改时间来查询，升序，有keyWords
   @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by  be_top desc,last_update_datetime desc")
    List<File> groupByUpdateTime2(String keywords,String username);//按修改时间来查询，降序，有keyWords

    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, title asc")
    List<File> groupByTitle(String keywords,String username);//按文件名称来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, title desc")
    List<File> groupByTitle2(String keywords,String username);//按文件名称来查询，降序，有keyWords

    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, size asc")
    List<File> groupBySize(String keywords,String username);//按文件大小来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, size desc")
    List<File> groupBySize2(String keywords,String username);//按文件大小来查询，降序，有keyWords

//be_star
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_star=1 and be_deleted=0 order by be_top desc, create_datetime asc")
    List<File> Star_CreateTime(String keywords,String username);//按创建时间来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_star=1 and be_deleted=0 order by be_top desc, create_datetime desc")
    List<File> Star_CreateTime2(String keywords,String username);//按创建时间来查询，降序，有keyWords

    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_star=1 and be_deleted=0 order by be_top desc, last_update_datetime asc")
    List<File> Star_UpdateTime(String keywords,String username);//按修改时间来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_star=1 and be_deleted=0 order by be_top desc, last_update_datetime desc")
    List<File> Star_UpdateTime2(String keywords,String username);//按修改时间来查询，降序，有keyWords

    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_star=1 and be_deleted=0 order by be_top desc, title asc")
    List<File> Star_Title(String keywords,String username);//按文件名称来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_star=1 and be_deleted=0 order by be_top desc, title desc")
    List<File> Star_Title2(String keywords,String username);//按文件名称来查询，降序，有keyWords

    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_star=1 and be_deleted=0 order by be_top desc, size asc")
    List<File> Star_Size(String keywords,String username);//按文件大小来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_star=1 and be_deleted=0 order by be_top desc, size desc")
    List<File> Star_Size2(String keywords,String username);//按文件大小来查询，降序，有keyWords

//be_delete
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=1 order by create_datetime asc")
    List<File> Delete_CreateTime(String keywords,String username);//按创建时间来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=1 order by create_datetime desc")
    List<File> Delete_CreateTime2(String keywords,String username);//按创建时间来查询，降序，有keyWords

    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=1 order by last_update_datetime asc")
    List<File> Delete_UpdateTime(String keywords,String username);//按修改时间来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=1 order by last_update_datetime desc")
    List<File> Delete_UpdateTime2(String keywords,String username);//按修改时间来查询，降序，有keyWords

   @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=1 order by title asc")
    List<File> Delete_Title(String keywords,String username);//按文件名称来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=1 order by title desc")
    List<File> Delete_Title2(String keywords,String username);//按文件名称来查询，降序，有keyWords

    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=1 order by size asc")
    List<File> Delete_Size(String keywords,String username);//按文件大小来查询，升序，有keyWords
    @Select("select * from searchFile where title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=1 order by size desc")
    List<File> Delete_Size2(String keywords,String username);//按文件大小来查询，降序，有keyWords

    //sign name  在某标签名下按orderName升降序
    @Select("select * from searchSignFile where title like concat('%',#{keywords},'%') and username=#{username} and name=#{name} and be_deleted=0 order by be_top desc, create_datetime asc")
    List<File> Sign_CreateTime(String keywords,String username,String name);//按创建时间来查询，升序，有keyWords
    @Select("select * from searchSignFile where title like concat('%',#{keywords},'%') and username=#{username} and name=#{name} and be_deleted=0 order by be_top desc, create_datetime desc")
    List<File> Sign_CreateTime2(String keywords,String username,String name);//按创建时间来查询，降序，有keyWords

    @Select("select * from searchSignFile where title like concat('%',#{keywords},'%') and username=#{username} and name=#{name} and be_deleted=0 order by be_top desc, last_update_datetime asc")
    List<File> Sign_UpdateTime(String keywords,String username,String name);//按修改时间来查询，升序，有keyWords
    @Select("select * from searchSignFile where title like concat('%',#{keywords},'%') and username=#{username} and name=#{name} and be_deleted=0 order by be_top desc, last_update_datetime desc")
    List<File> Sign_UpdateTime2(String keywords,String username,String name);//按修改时间来查询，降序，有keyWords

    @Select("select * from searchSignFile where title like concat('%',#{keywords},'%') and username=#{username} and name=#{name} and be_deleted=0 order by be_top desc, title asc")
    List<File> Sign_Title(String keywords,String username,String name);//按文件名称来查询，升序，有keyWords
    @Select("select * from searchSignFile where title like concat('%',#{keywords},'%') and username=#{username} and name=#{name} and be_deleted=0 order by be_top desc, title desc")
    List<File> Sign_Title2(String keywords,String username,String name);//按文件名称来查询，降序，有keyWords

    @Select("select * from searchSignFile where title like concat('%',#{keywords},'%') and username=#{username} and name=#{name} and be_deleted=0 order by be_top desc, size asc")
    List<File> Sign_Size(String keywords,String username,String name);//按文件大小来查询，升序，有keyWords
    @Select("select * from searchSignFile where title like concat('%',#{keywords},'%') and username=#{username} and name=#{name} and be_deleted=0 order by be_top desc, size desc")
    List<File> Sign_Size2(String keywords,String username,String name);//按文件大小来查询，降序，有keyWords

    //filePath路径下搜索排序
    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and username=#{username} and be_deleted=0")
    List<File> filePath(String username,String filePath);

    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, create_datetime asc")
    List<File> filePath_CreateTime(String keywords,String username,String filePath);//按创建时间来查询，升序，有keyWords
    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, create_datetime desc")
    List<File> filePath_CreateTime2(String keywords,String username,String filePath);//按创建时间来查询，降序，有keyWords

    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, last_update_datetime asc")
    List<File> filePath_UpdateTime(String keywords,String username,String filePath);//按修改时间来查询，升序，有keyWords
    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by last_update_datetime desc")
    List<File> filePath_UpdateTime2(String keywords,String username,String filePath);//按修改时间来查询，降序，有keyWords

    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, title asc")
    List<File> filePath_Title(String keywords,String username,String filePath);//按文件名称来查询，升序，有keyWords
    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, title desc")
    List<File> filePath_Title2(String keywords,String username,String filePath);//按文件名称来查询，降序，有keyWords

    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, size asc")
    List<File> filePath_Size(String keywords,String username,String filePath);//按文件大小来查询，升序，有keyWords
    @Select("select * from searchFile where path like concat('%',#{filePath},'%') and title like concat('%',#{keywords},'%') and username=#{username} and be_deleted=0 order by be_top desc, size desc")
    List<File> filePath_Size2(String keywords,String username,String filePath);//按文件大小来查询，降序，有keyWords

    @Select("select * from folder where path like concat('%',#{filePath},'%') and username=#{username} and be_deleted=0")
    List<Folder> SearchFolder(String username,String filePath);//搜索路径下的文件夹
    @Select("select * from folder where username=#{username} and be_deleted=1")
    List<Folder> SearchDeletdeFolder(String username);//搜索回收站中的文件夹

}
